//
//  FullWebViewController.m
//  Fangmm
//
//  Created by 阮琦 on 16/3/31.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "FullWebViewController.h"
#import "Utility.h"
#import "Constants.h"
#import <MobClick.h>

@interface FullWebViewController ()

@end

@implementation FullWebViewController {
    __weak IBOutlet UIWebView *webView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self configureNavigationBar];
    NSURL *url = [NSURL URLWithString:_destinationUrl];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    [self.view addSubview:webView];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(BOOL)shouldAutorotate {
    return NO;
}

- (void)viewWillAppear:(BOOL)animated {
    [Utility setObject:@"true" key:kCanBeLandScape];
    
    [[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
        NSNumber *a = [[NSNumber alloc]initWithInt:4];
        [[UIDevice currentDevice] performSelector:@selector(setOrientation:)withObject:a];
    }
    [MobClick beginLogPageView:@"全景视频页"];
    //    [[UIApplication sharedApplication] ];
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [Utility setObject:@"false" key:kCanBeLandScape];
    [[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationPortrait];
    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
        NSNumber *a = [[NSNumber alloc]initWithInt:1];
        [[UIDevice currentDevice] performSelector:@selector(setOrientation:)withObject:a];
    }
    [MobClick endLogPageView:@"全景视频页"];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)configureNavigationBar {
    self.title = self.titleString;
    self.navigationItem.hidesBackButton = true;
    UIImage *backImage = [[UIImage imageNamed:@"back-18-36"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc]initWithImage:backImage style:UIBarButtonItemStyleDone target:self action:@selector(clickToPopBack)];
    self.navigationItem.leftBarButtonItem = leftBarButton;
}

- (void)clickToPopBack {
    [self.navigationController popViewControllerAnimated:true];
}


@end
